/******************************************************
 * Project Aristo Wii - Compo NintendoMax 2011
 * ------------------------------------------
 * By : CORBEL Gabriel
 *      PERSON Thibault
 *      MAYANCE Damien
 * GameFerrero.cpp
 * 9 mars 2011
 *******************************************************/

#include "GameFerrero.h"

GameFerrero::GameFerrero() {

}

GameFerrero::~GameFerrero() {
}

void GameFerrero::initialize() {

}

void GameFerrero::load_content() {

	//Background
	//************************************************************
	ML_LoadBackgroundFromBuffer(&backgroundData, &background, bg_ferrero_png, 0, 0);

	//Sprites
	//************************************************************
	//Chargement du sprite de ferrero
	ML_LoadSpriteFromBuffer(&ferrero_sprite_data, &ferrero_sprites[0],
			ferrero_png, 0, 0);

	//Clonage pour les sprites restants
	for (int i = 1; i < MAX_FERRERO; ++i) {
		ML_CloneSprite(&ferrero_sprites[0], &ferrero_sprites[i]);
	}

	//Positionnement
	int x = 200;
	int y = 150;

	for (int i = 0; i < MAX_FERRERO; ++i) {
		ferrero_sprites[i].x = x;
		ferrero_sprites[i].y = y;
		ferrero_sprites[i].visible = true;

		x += 100;

		if(i == 3) {
			x = 180;
			y = 230;
		}
	}
}

void GameFerrero::unload_content() {
	ML_DeleteImage(&ferrero_sprite_data);
}

void GameFerrero::update(Gametime gametime) {

}

void GameFerrero::draw() {

	ML_DrawBackground(&background);

	for (int i = 0; i < MAX_FERRERO; ++i) {
		ML_DrawSprite(&ferrero_sprites[i]);
	}

	ML_DrawSpriteText(_context->get_font(), 20, 20, "Choississez le bon Ferrero !");
}

bool GameFerrero::isEnded() {
	return false;
}
